Advertisement
Guest User

Untitled

a guest
Jul 14th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.50 KB | None | 0 0
  1. --************************************************
  2. --*** Set these values up to suit your machine ***
  3. --************************************************
  4.  
  5. --this is the distance between each torch reference in MILLIMETRES
  6. refDistance = 250
  7.  
  8. --this is the reference feed rate in mm/min
  9. refFeed = 500
  10.  
  11. --Put your switch offset value here in MILLIMETRES
  12. switchOffset = 1.5
  13.  
  14. --Scriber X,Y,Z offsets in MILLIMETRES. Do not use inches here even if you want inch code
  15. --Use the special code 'nil' on the Z axis to disable it.
  16. --In that case no Z values will be output at all while scribing.
  17. --e.g scriberZ = nil
  18. scriberX = 110
  19. scriberY = 220
  20. scriberZ = 0
  21.  
  22. --scriber axis. Leave this as nil if the scriber is fixed to the same axis as the torch
  23. --scriberAxis = "A"
  24. scriberAxis = nil
  25.  
  26. --If this value is set to true then use G28 (home) for the Z reference
  27. --Set it to false for G31 probe
  28. refHome = true
  29.  
  30. --The cutter will slow down for corners and turn off THC below this radius
  31. slowRadius = 10
  32.  
  33. --Minimum slow down speed.
  34. --This is a scale factor. For instance 0.5 = 50% of the current feed rate
  35. slowPercent = 0.4
  36.  
  37. --THC on and off codes. Use nil if you don't want THC control e.g:
  38. -- thcOnCode = nil
  39. -- thcOffCode = nil
  40.  
  41. --here is another example that use M667 and M666
  42. --thcOnCode = " M667"
  43. --thcOffCode = " M666"
  44.  
  45. thcOnCode = " THC ON TEST"
  46. thcOffCode = " THC OFF TEST"
  47.  
  48. --************************************************
  49. --*** End of settings ***
  50. --************************************************
  51.  
  52.  
  53.  
  54. function OnAbout(event)
  55. ctrl = event:GetTextCtrl()
  56. ctrl:AppendText("plasma MP1000-THC post processor with engraver\n")
  57. ctrl:AppendText("\n")
  58. ctrl:AppendText("Modal G-codes and coordinates\n")
  59. ctrl:AppendText("Comments enclosed with ( and )\n")
  60. ctrl:AppendText("M03/M05 turn the torch on/off\n")
  61. ctrl:AppendText("M08/M09 turn the engraver on/off\n")
  62. ctrl:AppendText("Incremental IJ - set in mach2\n")
  63. ctrl:AppendText("The torch is referenced at cut start and every 500mm of movement thereafter\n")
  64. ctrl:AppendText("Designed for use with Mach3 and CandCNC MP1000-THC and Floating head Touch-n-Go\n")
  65. ctrl:AppendText("Post variables:\n")
  66. ctrl:AppendText("refDistance - set the distance between each reference\n")
  67. ctrl:AppendText("refFeed - set the feed rate when referencing\n")
  68. ctrl:AppendText("switchOffset - set your net switch offset amount \n")
  69. ctrl:AppendText("Scriber uses any tool number\n")
  70. ctrl:AppendText("slowRadius - slow down below this radius\n")
  71. ctrl:AppendText("slowPercent - minimum percentage to slow down\n")
  72. end
  73.  
  74.  
  75.  
  76. -- created 1/1/06
  77. -- Based on plasma1.post
  78.  
  79.  
  80. -- Modified 21/6/2010
  81. -- added option for 'nil' plate marker z
  82. -- Added support for plate marker tool type as well as tool number based plate marker
  83.  
  84. -- Modified 4/11/2010
  85. -- Added: Reference the torch on the first pen down if the plate marker is the first tool used.
  86.  
  87.  
  88. post.DefineVariable("refDistance",sc.unitLINEAR,0,1e17)
  89. post.DefineVariable("refFeed",sc.unitFEED,0,1e17)
  90. post.DefineVariable("switchOffset",sc.unitLINEAR,-1e17,1e17)
  91. post.DefineVariable("slowRadius",sc.unitLINEAR,-1e17,1e17)
  92. post.DefineVariable("slowPercent",sc.unitPERCENT,-1e17,1e17)
  93.  
  94. function OnInit()
  95.  
  96. offX = 0
  97. offY = 0
  98. offZ = 0
  99.  
  100. post.SetCommentChars ("()", "[]") --make sure ( and ) characters do not appear in system text
  101. post.Text (" (Filename: ", fileName, ")\n")
  102. post.Text (" (Post processor: ", postName, ")\n")
  103. post.Text (" (Date: ", date, ")\n")
  104. if(scale == metric) then
  105. post.Text (" G21 (Units: Metric)\n") --metric mode
  106. else
  107. post.Text (" G20 (Units: Inches)\n") --inch mode
  108. end
  109. post.Text (" F1\n G53 G90 G40\n")
  110. minArcSize = 0.2 --arcs smaller than this are converted to moves
  111. firstRef = true
  112. currentZAxis = "Z"
  113.  
  114. dist = 9999999
  115. lastz = 0
  116. thcstate = 1
  117. ThcOff()
  118. end
  119.  
  120. function OnNewLine()
  121. post.Text ("N")
  122. post.Number (lineNumber, "0000")
  123. lineNumber = lineNumber + 10
  124. end
  125.  
  126.  
  127. function OnFinish()
  128. endZ = safeZ
  129. OnRapid()
  130. endX = 0
  131. endY = 0
  132. offX = 0
  133. offY = 0
  134. offZ = 0
  135. OnRapid()
  136. post.Text (" M05 M30\n")
  137. end
  138.  
  139. function OnRapid()
  140. if(endX > 1e17 and endY > 1e17) then return end
  141. local len = math.hypot((endX + offX)-currentX , (endY + offY)-currentY)
  142. dist = dist + len
  143. post.ModalText (" G00")
  144. post.ModalNumber (" X", (endX + offX) * scale, "0.0000")
  145. post.ModalNumber (" Y", (endY + offY) * scale, "0.0000")
  146. if(offZ and firstRef == false and currentZ ~= safeZ) then
  147. post.ModalNumber (" " .. currentZAxis, (endZ + offZ) * scale, "0.0000")
  148. end
  149. post.Eol()
  150. end
  151.  
  152. function OnMove()
  153. local len = math.hypot(endX - currentX , endY - currentY)
  154. dist = dist + len
  155. if(len > slowRadius) then
  156. ThcOn()
  157. end
  158. post.ModalText (" G01")
  159. post.ModalNumber (" X", (endX + offX) * scale, "0.0000")
  160. post.ModalNumber (" Y", (endY + offY) * scale, "0.0000")
  161. if(offZ) then
  162. post.ModalNumber (" " .. currentZAxis, (endZ + offZ) * scale, "0.0000")
  163. end
  164. post.ModalNumber (" F", feedRate * scale, "0.0###")
  165. post.Eol()
  166. end
  167.  
  168. function OnArc()
  169. local radius = math.hypot(currentX - arcCentreX, currentY - arcCentreY)
  170. dist = dist + radius * math.abs(arcAngle)
  171.  
  172. if (radius < slowRadius) and (math.abs(arcAngle) > 0.5) then
  173. feed = (radius / slowRadius)
  174. if(feed < slowPercent) then
  175. feed = slowPercent
  176. end
  177. feed = feed * feedRate
  178. ThcOff()
  179. else
  180. feed = feedRate
  181. ThcOn()
  182. end
  183. if(arcAngle <0) then
  184. post.ModalText (" G03")
  185. else
  186. post.ModalText (" G02")
  187. end
  188. post.ModalNumber (" X", (endX + offX) * scale, "0.0000")
  189. post.ModalNumber (" Y", (endY + offY) * scale, "0.0000")
  190. if(offZ) then
  191. post.ModalNumber (" " .. currentZAxis, (endZ + offZ) * scale, "0.0000")
  192. end
  193. post.Text (" I")
  194. post.Number ((arcCentreX - currentX) * scale, "0.0000")
  195. post.Text (" J")
  196. post.Number ((arcCentreY - currentY) * scale, "0.0000")
  197. post.ModalNumber (" F", feed * scale, "0.0###")
  198. post.Eol()
  199. end
  200.  
  201.  
  202. function ThcOff()
  203. if(not thcOffCode) then return end
  204. if(thcstate ==1) then
  205. thcstate = 0
  206. post.Text(thcOffCode)
  207. post.Text(" (THC off)\n");
  208. end
  209. end
  210.  
  211. function ThcOn()
  212. if(not thcOnCode) then return end
  213. if(toolClass == "MarkerTool") or tool > 99 then return end
  214. if(thcstate ==0) then
  215. thcstate = 1
  216. post.Text(thcOnCode)
  217. post.Text(" (THC on)\n");
  218. return
  219. end
  220. if(thcstate == 2) then
  221. thcstate = 0
  222. end
  223. end
  224.  
  225.  
  226. function OnPenDown()
  227. if(toolClass == "MarkerTool") or tool > 99 then
  228. if (firstRef) then
  229. Reference()
  230. post.ModalText (" G00")
  231. post.Text(" Z")
  232. post.Number (safeZ * scale, "0.0000")
  233. post.Eol()
  234. offX = scriberX
  235. offY = scriberY
  236. offZ = scriberZ
  237. post.ModalNumber (" X", (currentX + offX) * scale, "0.0000")
  238. post.ModalNumber (" Y", (currentY + offY) * scale, "0.0000")
  239. post.Eol()
  240. end
  241. if (offZ) then
  242. post.ModalNumber (" " .. currentZAxis, (currentZ + offZ) * scale, "0.0000")
  243. post.Eol()
  244. end
  245. post.Text(" M08\n")
  246. else
  247. if(dist >= refDistance) then
  248. dist = 0
  249. Reference();
  250. end
  251. post.ModalText (" G00")
  252. post.Text(" Z")
  253. post.Number (pierceHeight * scale, "0.0000")
  254. post.Eol()
  255. if (preheat > 0) then
  256. post.Text ("\n G04 P")
  257. post.Number (preheat,"0.###")
  258. post.Eol()
  259. end
  260. post.Text ("\n M03\n")
  261. end
  262. if (pierceDelay > 0) then
  263. post.Text (" G04 P")
  264. post.Number (pierceDelay,"0.###")
  265. post.Eol()
  266. end
  267. -- thcstate = 2 --leave THC off for plunge move
  268. end
  269.  
  270.  
  271. function Reference()
  272. firstRef = false
  273. if (refHome) then
  274. post.ModalText(" G28.1 Z")
  275. post.Number(3 * scale, "0.00")
  276. else
  277. post.ModalText(" G31 Z -100")
  278. end
  279. post.ModalNumber (" F", refFeed * scale, "0.0###")
  280. post.Eol()
  281. post.ModalText(" G92 Z0.0\n")
  282. post.ModalText (" G00")
  283. post.Text(" Z")
  284. post.Number (switchOffset * scale, "0.0000")
  285. post.Eol()
  286. post.ModalText(" G92 Z0.0\n")
  287. end
  288.  
  289. function OnPenUp()
  290. if(tool > 99) then
  291. post.Text(" M09\n")
  292. else
  293. post.Text (" M05\n")
  294. end
  295. if (endDelay > 0) then
  296. post.Text (" G04 P")
  297. post.Number (endDelay,"0.###")
  298. post.Eol()
  299. end
  300. end
  301.  
  302.  
  303. function OnNewOperation()
  304. post.Text (" (Operation: ", operationName, ")\n")
  305. end
  306.  
  307. function OnToolChange()
  308. if (toolClass == "MarkerTool" or tool > 99 ) then
  309. ThcOff()
  310. if(scriberAxis and scriberAxis ~= currentZAxis) then
  311. endZ = safeZ
  312. OnRapid()
  313. currentZAxis = scriberAxis
  314. end
  315. if(firstRef ~= true) then
  316. offX = scriberX
  317. offY = scriberY
  318. offZ = scriberZ
  319. end
  320. else
  321. if(scriberAxis and scriberAxis == currentZAxis) then
  322. endZ = safeZ
  323. OnRapid()
  324. currentZAxis = "Z"
  325. end
  326. offX = 0
  327. offY = 0
  328. offZ = 0
  329. end
  330. end
  331.  
  332. function OnNewPart()
  333. post.Text(" (Part: ",partName,")\n");
  334. end
  335.  
  336. function OnDrill()
  337. OnRapid()
  338. currentX = endX
  339. currentY = endY
  340. OnPenDown()
  341. endZ = drillZ
  342. OnMove()
  343. OnPenUp()
  344. endZ = safeZ
  345. OnRapid()
  346. end
  347.  
  348.  
  349. function OnComment()
  350. post.Text(" (",commentText,")\n")
  351. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement